package pl.poznan.put.cs.idss.students.coolring.ui;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;

import javax.swing.JFrame;

import pl.poznan.put.cs.idss.students.coolring.properties.Properties;

public class SplashScreen extends JFrame {

	private static final long serialVersionUID = 5290226956246080727L;

	Image image = Toolkit.getDefaultToolkit()
			.getImage(
					SplashScreen.class.getResource(Properties
							.get("splashscreen_image")));

	Image icon = Toolkit.getDefaultToolkit().getImage(
			SplashScreen.class.getResource(Properties.get("application_icon")));

	private boolean isTimeUp = false;

	public SplashScreen(int duration) throws InterruptedException {

		setSize(Properties.number("splashscreen_width"),
				Properties.number("splashscreen_height"));
		setLocationRelativeTo(null);
		setUndecorated(true);
		setIconImage(icon);
		setBackground(new Color(210, 210, 210, 0));
		setVisible(true);
		Thread.sleep(duration);
		isTimeUp = true;

	}

	public void paint(Graphics g) {
		g.drawImage(image, 0, 0, this);
	}

	public boolean isTimeUp() {
		return isTimeUp;
	}

}
